{include 'header.tpl'}
<ol class="breadcrumb">
    <li><a href="/adminmall/User/shopTj">收入利润统计</a></li>
</ol>
<form method="get" action="/adminmall/User/shopTj" class="form-inline">
    <table>
        <tr>
            <td>
                <label for="form-w" class="control-label">连锁店：</label>
                <select name="shop_id" class="form-control" >
                    <option value="">--请选择连锁店--</option>
                    {foreach $chainData as $key => $value}
                        <option value="{$value['id']}" {if $smarty.get.shop_id eq $value['id']}selected="selected"{/if}>{$value['name']}</option>
                    {/foreach}
                </select>
            </td>

            <td>
                <label for="form-w" class="control-label">时间范围：</label>
                <input type="text" class="date-picker" id="begin_date" name="begin_date" value="{$start_time}" style="width: 85px;"/> 至 <input type="text" class="date-picker" id="end_date" name="end_date" value="{$end_time}" style="width: 85px;"/>
            </td>

            <td>
                <button type="submit" class="btn btn-primary">查找</button>
                <a href="/adminmall/User/tjAdmin" class="btn btn-danger">清空条件</a>
                {*<button type="button" onclick="dao()" class="btn btn-primary">导出</button>*}
            </td>
        </tr>
    </table>
</form>
<div class="clearfix" style="height:30px;"></div>

<table class="fTable" style="width: 60%">
    <thead>
    <tr>
        <th>类型</th>
        <th>收入金额</th>
    </tr>
    </thead>
    <tbody>
    <tr style="color: red;font-size: 110%;">
        <td>当天收入金额</td>
        <td>¥{$tongji['today_income']}</td>
    </tr>
    <tr style="color: red;font-size: 110%;">
        <td>昨天收入金额</td>
        <td>¥{if $tongji['yesterday_income'] eq ""}0.00{else}{$tongji['yesterday_income']}{/if}</td>
    </tr>
    <tr style="color: red;font-size: 110%;">
        <td>周收入金额</td>
        <td>¥{$tongji['week_income']}</td>
    </tr>
    <tr style="color: red;font-size: 110%;">
        <td>本月收入金额</td>
        <td>¥{$tongji['month_income']}</td>
    </tr>
    <tr style="color: red;font-size: 110%;">
        <td>上月收入金额</td>
        {*<td>¥{$tongji['lastmonth_income']}</td>*}
        <td>¥{if $tongji['lastmonth_income'] eq ""}0.00{else}{$tongji['lastmonth_income']}{/if}</td>
    </tr>
    <tr style="color: red;font-size: 110%;">
        <td>所有收入金额</td>
        <td>¥{$tongji['all_income']}</td>
    </tr>
    </tbody>
</table>

<br>
<br>


<table class="table" style="table-layout: fixed;WORD-BREAK: break-all; WORD-WRAP: break-word">
    <tr>
        <td>日期</td>
        <td>店铺</td>
        <td>商品收入</td>
        <td>配送收入</td>
        <td>优惠金额</td>
        <td>总收入</td>
        <td>商品结算成本</td>
        <td>配送成本</td>
        <td>利润</td>
        <td>接单量</td>
        <td>平均接单耗时</td>
        <td>平均制作耗时</td>
        <td>平均配送耗时</td>
        <td>平均配送距离km）</td>



    </tr>
    {foreach $data as $key => $value}
        {*{var_dump($data[$key])}*}
        {foreach $data[$key] as $k1 => $v1}

            {*########{var_dump($v1)}*}
            {foreach $v1 as $k2 => $v2}
                {if $v2['shop_id'] neq ""}
                <tr>
                    <td>{$key}</td>
                    <td>
                        {foreach $chainData as $k => $v}
                            {if $v['id'] eq $v2['shop_id']}{$v['name']}{/if}
                        {/foreach}
                    </td>
                    <td>{$v2['price_sum']}</td>
                    <td>{$v2['send_price_sum']}</td>
                    <td>{$v2['youhui_price_sum']}</td>
                    <td>{$v2['pay_price_sum']}</td>
                    <td>{$v2['purchase_price_sum']}</td>
                    <td>{$v2['real_send_price_sum']}</td>
                    <td>{$v2['profit_sum']}</td>
                    <td>{$v2['count_sum']}</td>
                    <td>{Service_Order::timeFormat($v2['recv_expend_sum'])}</td>
                    <td>{Service_Order::timeFormat($v2['make_expend_sum'])}</td>
                    <td>{Service_Order::timeFormat($v2['send_expend_sum'])}</td>
                    <td>{$v2['dis_sum']}</td>
                </tr>
                {/if}
            {/foreach}


        {/foreach}
    {/foreach}
    <tr>
        <td colspan="2">所有</td>
        <td>{$huizong['price_sum']}</td>
        <td>{$huizong['send_price_sum']}</td>
        <td>{$huizong['youhui_price_sum']}</td>
        <td>{$huizong['pay_price_sum']}</td>
        <td>{$huizong['purchase_price_sum']}</td>
        <td>{$huizong['real_send_price_sum']}</td>
        <td>{$huizong['profit_sum']}</td>
        <td>{$huizong['count_sum']}</td>
        <td colspan="5"></td>
    </tr>
</table>
{include "pager.tpl"}
<script type="text/javascript">
    $(function () {
        create_date_picker();
    });

    function dao(){
        var nickname = $('#nickname').val();
        var mobile = $('#mobile').val();
        var begin_date = $('#begin_date').val();
        var end_date = $('#end_date').val();
        var intentionE1=$("#intention option:selected");
        var intention = intentionE1.val();
//        alert(intention);
//        alert(nickname);
//        alert(mobile);
//        alert(end_date);

        location.href = "/admin/Order/excelDao?begin_date=" + begin_date + "&end_date=" + end_date+ "&nickname=" + nickname+ "&mobile=" + mobile + "&intention=" + intention;

    }
</script>
{include 'footer.tpl'}